package com.mxf.code.strategy_factory.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxf.code.strategy_factory.enums.StatisticalIndicatorsEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 统计图Request
 */
@Data
@ApiModel(value = "统计图Request")
public class StatisticsRequest implements Serializable {
    private static final long serialVersionUID = 1L;

    @NotBlank(message = "统计指标不能为空")
    @ApiModelProperty(value = "统计指标")
    private StatisticalIndicatorsEnum statisticalIndicatorsEnum;

    @NotNull(message = "统计起始时间不能为空")
    @ApiModelProperty(value = "开始时间，格式：yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date startDate;

    @NotNull(message = "统计截止时间不能为空")
    @ApiModelProperty(value = "结束时间（格式：yyyy-MM-dd）")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    @ModelAttribute("statisticalIndicators")
    public void setStatisticalIndicatorsEnum(StatisticalIndicatorsEnum statisticalIndicatorsEnum) {
        this.statisticalIndicatorsEnum = statisticalIndicatorsEnum;
    }
}
